package com.atguigu.security.custom;

import com.atguigu.common.utils.Md5;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

/**
 * className: CustomMd5PasswordEncoder
 * description: 密码处理
 * date: 2023/4/17 0017-21:59
 * <p>
 * project: guigu-oa-parent
 * package: com.atguigu.security.custom
 * email: 1085844536@qq.com
 * version:
 *
 * @author WangGuojian
 */
@Component
public class CustomMd5PasswordEncoder implements PasswordEncoder {

    @Override
    public String encode(CharSequence rawPassword) {
        return Md5.encrypt(rawPassword.toString());
    }

    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {
        return encodedPassword.equals(Md5.encrypt(rawPassword.toString()));
    }
}
